package Reference;

import java.lang.ref.WeakReference;

/**
 * @Author: dch
 * @Date: 2020/5/18 13:55
 * @Description:
 */
public class WeakReferenceDemo {
    public static void main(String[] args) {
        Object obj1 = new Object();
        WeakReference<Object> weakReference = new WeakReference<Object>(obj1);
        //回收前
        System.out.println(obj1);
        System.out.println(weakReference.get());

        obj1 = null;
        System.gc();
        System.out.println("===========回收分界线===========");
        System.out.println(obj1);
        System.out.println(weakReference.get());
    }
}
